<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>去报价</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui.css" />
    <style>
        body {
            background: #fff;
        }

        .aui-list-item-input input {
            text-align: right;
        }

        .btn {
            background: #0689FB;
            width: 7rem;
            height: 2rem;
            text-align: center;
            line-height: 2rem;
            color: #fff;
            margin: 10rem auto 0;
            border-radius: 0.2rem;
        }

        .aui-checkbox {
            width: 0.6rem;
            height: 0.6rem;
            margin-top: 0.15rem;
            margin-left: 0.5rem;
            border-radius: 50%;
        }

        .statement {
            color: #0689FB;
            margin-right: 0.5rem;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="aui-content">
            <div class="aui-list">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">所需工期</div>
                        <div class="aui-list-item-input">
                            <input type="number" v-model="info.work_time" placeholder="请输入工期天数">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">所需费用</div>
                        <div class="aui-list-item-input">
                            <input type="number" v-model="info.order_price" placeholder="请输入费用金额">
                        </div>
                    </div>
                </li>
            </div>
            <div style="font-size:0.6rem;margin-top:1rem;">
                <label><input class="aui-checkbox" type="checkbox" v-model="tongyi" name="demo1"> 同意</label>
                <span @click="openWin('arcarc')" class="statement">服务条款</span>
            </div>
            <div>
                <div class="btn" @click="submit()">立即提交</div>
            </div>
        </div>
    </div>
</body>
<script src="../../../script/api.js" charset="utf-8"></script>
<script src="../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../script/common/check.js" charset="utf-8"></script>
<script src="../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            orderInfo: {},
            tongyi:true,
            info: {
                work_time: '',
                order_price: ''
            }
        },
        methods: {
            init() {
                this.orderInfo = api.pageParam;
            },
            submit() {
                if (!is_define(this.info.work_time)) {
                    $toast("请填写工期");
                    return;
                } else if (!is_define(this.info.order_price)) {
                    $toast("请填写费用");
                    return;
                }
                if(!this.tongyi){
                  $toast("请阅读并同意服务条款");
                  return;
                }
                var data = {
                    order_id: this.orderInfo.order_id,
                    work_id: this.orderInfo.work_id,
                    work_user_id: this.orderInfo.work_user_id,
                    accept_user_id: this.orderInfo.accept_user_id,
                    work_time: this.info.work_time,
                    order_price: this.info.order_price,
                };
                _ajax(Config.api.AcceptUserGoOffer, data, function(ret) {
                    if (ret.code === 200) {
                        $toast("提交成功");
                        api.execScript({
                            name: "get_work_win",
                            frameName: "get_work_frm",
                            script: 'vm.getList()'
                        });
                        setTimeout(function() {
                            close_w();
                        }, 1000);
                    }
                });
            },
            openWin() {
                var url = {
                    1: Config.api.NewsContractTreaty,
                    2: Config.api.NewsEngageTreaty,
                };
                var winInfo = {
                    name: 'arc_arc_win',
                    url: '../../arc/arc_arc_win.html',
                    pageParam: {
                        title: '服务条款',
                        url: url[this.orderInfo.work_nature]
                    }
                }
                open_w(winInfo.name, winInfo.url, winInfo.pageParam);
            }
        }
    });
</script>

</html>
